Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/pnp

Package Overview
Dependencies
Maintainers
0
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/pnp

  • 3.3.8
  • v3
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is @yarnpkg/pnp?

@yarnpkg/pnp is a package that provides Plug'n'Play (PnP) functionality for Yarn, a popular JavaScript package manager. PnP is a feature that eliminates the need for a node_modules directory by resolving dependencies directly from the Yarn cache, leading to faster installs and more efficient disk usage.

What are @yarnpkg/pnp's main functionalities?

Dependency Resolution

This feature allows you to resolve the path to a dependency without needing a node_modules directory. The code sample demonstrates how to resolve the path to the 'lodash' package.

const { resolveToUnqualified, resolveUnqualified } = require('@yarnpkg/pnp');

const unqualifiedPath = resolveToUnqualified('lodash', __filename);
const qualifiedPath = resolveUnqualified(unqualifiedPath, 'lodash');

console.log(qualifiedPath);

Package Information

This feature provides detailed information about a specific package, such as its location and dependencies. The code sample shows how to retrieve information for the 'lodash' package.

const { getPackageInformation } = require('@yarnpkg/pnp');

const packageLocator = { name: 'lodash', reference: '4.17.21' };
const packageInfo = getPackageInformation(packageLocator);

console.log(packageInfo);

Custom Resolvers

This feature allows you to create custom resolvers for specific packages. The code sample demonstrates how to create a custom resolver for a package named 'custom-package'.

const { makeResolver } = require('@yarnpkg/pnp');

const customResolver = makeResolver({
  resolveToUnqualified: (request, issuer) => {
    if (request === 'custom-package') {
      return '/path/to/custom-package';
    }
    return null;
  }
});

console.log(customResolver.resolveToUnqualified('custom-package', __filename));

Other packages similar to @yarnpkg/pnp

FAQs

Package last updated on 21 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc